package adminLoginPack;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import Notifications.notificationsDataLoading;



public class AddPostUrQueriesAction extends Action {


	  public ActionForward execute(ActionMapping mapping, ActionForm inForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
		 
		  try{
			  
			  int isUpdate = 0;
			  
			  	
			 
			  String userId = null != request.getSession().getAttribute("UserID")?(String)request.getSession().getAttribute("UserID"):"" ;
			  String selectedPostQueries = null != request.getParameter("selectedPostQueries")?request.getParameter("selectedPostQueries"):"";
			  notificationsDataLoading ndg = new notificationsDataLoading();
			 
			  if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("suooii")){
					  String textlable ="suooii~Q" ;
					  boolean flag = ndg.updatePostYourQueiries(request, textlable, 1, 6, userId, selectedPostQueries,null);
					  if(flag){
						isUpdate = 1;  
					  }
					  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("compouund")){
				  String textlable ="compouund~Q" ;
				  String text = request.getParameter("compouund~Q7");
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 7, 12, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("IBIP")){
				  String textlable ="IBIP~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 13, 20, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("PRIIIFS")){
				  String textlable ="PRIIIFS~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 21, 25, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if (!"".equals(selectedPostQueries) &&  selectedPostQueries.contains("IIIS")){
				 int n = selectedPostQueries.lastIndexOf('N');
				 String textlable = "";
				 String isIIIS = "";
				 if(n== 4){
					 textlable ="IIISN~Q" ;
					 isIIIS = "N";
				 }else{
					 textlable ="IIIS~Q" ;
					 isIIIS = "Y";
				 }
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 26, 32, userId, selectedPostQueries,isIIIS);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("BDIR")){
				  String textlable ="BDIR~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 33, 38, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("PER")){
				  String textlable ="PER~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 39, 44, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }
			  else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("BOOA")){
				  String textlable ="BOOA~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 45, 47, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("EOGAS")){
				  String textlable ="EOGAS~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 48, 51, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("IOGAS")){
				  String textlable ="IOGAS~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 52, 54, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  } else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("IPOA")){
				  String textlable ="IPOA~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 61, 64, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  } else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("ECB")){
				  String textlable ="ECB~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 65, 72, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("FER")){
				  String textlable ="FER~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 41, 44, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("IPOI")){
				  String textlable ="IPOI~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 61, 64, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }else if(!"".equals(selectedPostQueries) &&  selectedPostQueries.equals("IPII")){
				  String textlable ="IPII~Q" ;
				  boolean flag = ndg.updatePostYourQueiries(request, textlable, 55, 60, userId, selectedPostQueries,null);
				  if(flag){
					isUpdate = 1;  
				  }
				  request.setAttribute("isUpdated", isUpdate);
			  }
			  
			  if(isUpdate == 1 || isUpdate == 2){
					response.getWriter().write("<table width='100%'   border='1' cellspacing='0' cellpadding='0'><tr><td align='center'><font style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px' color='blue' size='12' >Your Query Is Submited Successfully... We Will Get Back To You Soon...</font></td></tr></table>");
				}
				
		  }catch(Exception e){
			  e.printStackTrace();
			  response.getWriter().write("<table width='100%'   border='1' cellspacing='0' cellpadding='0'><tr><td align='center'><font style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px' color='blue' size='12' >Sorry some thing went wrong, you request is not processed... Please try again...</font></td></tr></table>");
		  }finally{
			  
		  }
		   
		  return null;
	    
	  }
	  
	  
	  
	    
}
